using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DialogueTrigger
{
    public Entity entityNPC;
    public Entity entityPlayer;



    private float GetDistance()
    {
        int gridX1;
        int gridY1;
        int gridX2;
        int gridY2;
        entityNPC.GetGrid(out gridX1, out gridY1);
        entityPlayer.GetGrid(out gridX2, out gridY2);
        //Debug.Log(gridX1 + ":" + gridY1 + ":" + gridX2 + ":" + gridY2);
        return Mathf.Sqrt((gridX1 - gridX2) * (gridX1 - gridX2) + (gridY1 - gridY2) * (gridY1 - gridY2));
    }

    public void Detect()
    {
        //Debug.Log("GetDistance():" + GetDistance());
        if (GetDistance() > 1.5f)
        {
            Dialogue.Instance.Hide();
        }
        else
        {
            Dialogue.Instance.Show((entityNPC as NPC).GetTaskId());
        }
    }
}
